package com.szpt.mo.bhubackground.util.config;

import com.alibaba.druid.util.StringUtils;
import com.szpt.mo.bhubackground.entity.TbUser;
import com.szpt.mo.bhubackground.entity.parameters.R_Result;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

public class StatusCheckUtils {

    public static boolean isAdmin(HttpServletRequest request) {
        HttpSession session = request.getSession();
        TbUser user = (TbUser) session.getAttribute("user");
        if (user == null) {
            return false;
        }
        return StringUtils.equals("admin", user.getRole());
    }
    public static TbUser isLogin(HttpServletRequest request) {
        HttpSession session = request.getSession();
        TbUser user = (TbUser) session.getAttribute("user");
        if (user == null) {
            return null;
        }
        return user;
    }
}
